package com.financial.common.exception;

import com.financial.common.constants.ResultCodeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author: 周未
 * @Description:
 * @create 13:23 2019/12/31
 */
@Data
@ApiModel (value = "全局异常")
public class TsException extends RuntimeException {
	private static final long serialVersionUID = -7182343806765090516L;
	@ApiModelProperty (value = "状态码")
	private Integer code;

	/**
	 * 接受状态码和消息
	 *
	 * @param code
	 * @param message
	 */
	public TsException(Integer code, String message) {
		super(message);
		this.code = code;
	}

	/**
	 * 接收枚举类型
	 *
	 * @param resultCodeEnum
	 */
	public TsException(ResultCodeEnum resultCodeEnum) {
		super(resultCodeEnum.getMessage());
		code = resultCodeEnum.getCode();
	}

	@Override
	public String toString() {
		return "TsException{" +
				"message=" + getMessage() +
				", code=" + code +
				'}';
	}
}